package avicit.im.lantop.docmanager.deptdocarrange.action.rest;


import avicit.im.lantop.basic.fieldmapset.action.rest.LantopFieldMapSetServiceRest;
import avicit.im.lantop.docmanager.deptdocarrange.action.service.DeptdocarrangeService;
import avicit.im.lantop.docmanager.deptdocarrange.service.api.DeptdocarrangeServiceApi;
import avicit.platform6.commons.utils.web.TreeNode;
import avicit.platform6.core.rest.msg.ResponseMsg;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@Api(tags = "LantopFieldMapSetService", description = "LantopFieldMapSetService")
@RequestMapping("/api/avicit/im/lantop/docmanager/deptdocarrange/action/rest/DeptdocarrangeServiceRest")
public class DeptdocarrangeServiceRest {

    private static final Logger LOGGER = LoggerFactory.getLogger(DeptdocarrangeServiceRest.class);



    @Autowired(required = true)
    private DeptdocarrangeService deptdocarrangeService;


    /**
     * 通过数据id获得附件id
     * @param id
     * @return
     */
    @PostMapping("/getSourceNames")
    @ApiOperation(value = "通过数据id获得附件id")
    public ResponseMsg<List<Map<String, Object>>> getSourceNames(@ApiParam(value = "通过数据id获得附件id", name = "id") @RequestBody String id) {
        ResponseMsg<List<Map<String, Object>>> responseMsg = new ResponseMsg<>();
        try {
            List<Map<String, Object>> sourceNames = deptdocarrangeService.getSourceNames(id);
            responseMsg.setResponseBody(sourceNames);
            responseMsg.setRetCode("200");
        } catch (Exception e) {
            responseMsg.setRetCode("201");
            responseMsg.setErrorDesc(e.getMessage());
            e.printStackTrace();
        }
        return responseMsg;
    }


    /**
     * 通过数据id获得附件id
     * @param id
     * @return
     */
    @PostMapping("/getSourceName")
    @ApiOperation(value = "通过数据id获得附件id")
    public ResponseMsg<List<Map<String, Object>>> getSourceName(@ApiParam(value = "通过数据id获得附件id", name = "id") @RequestBody String id) {
        ResponseMsg<List<Map<String, Object>>> responseMsg = new ResponseMsg<>();
        try {
            List<Map<String, Object>> sourceName = deptdocarrangeService.getSourceName(id);
            responseMsg.setResponseBody(sourceName);
            responseMsg.setRetCode("200");
        } catch (Exception e) {
            responseMsg.setRetCode("201");
            responseMsg.setErrorDesc(e.getMessage());
            e.printStackTrace();
        }
        return responseMsg;
    }
}
